# -*- coding: utf-8 -*- 

from numpy import *

array = random.rand(4, 4)

print array#随机4 * 4数组
print "----------------------------------------"

randMat = mat(array) #数组转换成矩阵

print randMat
print "----------------------------------------"

invRandMat = randMat.I #矩阵求逆

print invRandMat 
print "----------------------------------------"

myEye = randMat * invRandMat#矩阵相乘

print myEye
print "----------------------------------------"

pure = myEye - eye(4, 4)#eye(4, 4) 创建单位矩阵

print pure

"""
[[0.59774478 0.27667655 0.83676654 0.34214905]
 [0.15510116 0.34282224 0.67390717 0.82408148]
 [0.74861786 0.72573314 0.76544715 0.04513842]
 [0.73328569 0.08812684 0.72491471 0.48711059]]
----------------------------------------
[[0.59774478 0.27667655 0.83676654 0.34214905]
 [0.15510116 0.34282224 0.67390717 0.82408148]
 [0.74861786 0.72573314 0.76544715 0.04513842]
 [0.73328569 0.08812684 0.72491471 0.48711059]]
----------------------------------------
[[-3.08488433 -0.49366735  1.05662269  2.90410042]
 [-2.21556483  0.95867519  1.79791501 -0.23224319]
 [ 5.28389187 -0.50394398 -1.44547134 -2.72492819]
 [-2.81870016  1.319681    0.2352496   1.77838899]]
----------------------------------------
[[ 1.00000000e+00  1.11022302e-16  1.38777878e-17  1.11022302e-16]
 [-4.44089210e-16  1.00000000e+00  1.38777878e-16  2.22044605e-16]
 [-3.60822483e-16  2.08166817e-17  1.00000000e+00 -8.32667268e-17]
 [-6.66133815e-16  1.11022302e-16 -1.66533454e-16  1.00000000e+00]]
----------------------------------------
[[ 0.00000000e+00  1.11022302e-16  1.38777878e-17  1.11022302e-16]
 [-4.44089210e-16  0.00000000e+00  1.38777878e-16  2.22044605e-16]
 [-3.60822483e-16  2.08166817e-17 -1.11022302e-16 -8.32667268e-17]
 [-6.66133815e-16  1.11022302e-16 -1.66533454e-16  0.00000000e+00]]
"""
